package On_class.L0416;

import java.io.InputStream;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

public class JdbcUtils {
    private static String url;
    private static String user;
    private static String password;

    static {
        try{
            Properties pro=new Properties();
            InputStream is= JdbcUtils.class.getClassLoader().getResourceAsStream("jdbc.properties");
            pro.load(is);
            url=pro.getProperty("url");
            user=pro.getProperty("user");
            password=pro.getProperty("password");
            String driver=pro.getProperty("driver");
            Class.forName(driver);


        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public static void close(ResultSet rs, Statement stmt, Connection conn){
        if (rs!=null){
            try {
                rs.close();
                stmt.close();
                conn.close();
            }catch (SQLException e){
                e.printStackTrace();
            }
        }

    }
}
